var aiEnableCookie=false; var aiId=''; var aiExtraSpace=0; var aiAccTime=0; var aiOnloadEventsCounter=0; var aiCallbackExists=typeof aiReadyCallbacks!=='undefined'&&aiReadyCallbacks instanceof Array; var aiReadyCallbacks=aiCallbackExists ? aiReadyCallbacks:[]; function aiResizeIframe(obj, resizeWidth, resizeMinHeight){ try { if(obj.contentWindow.location.href==='about:blank'){ return; } if(obj.contentWindow.document.body!=null){ var oldScrollposition=jQuery(window).scrollTop(); obj.style.marginTop=0; obj.style.marginBottom=0; obj.height=Number(resizeMinHeight); obj.style.height=Number(resizeMinHeight) + 'px'; var newheight=aiGetIframeHeight(obj); obj.height=newheight; obj.style.height=newheight + 'px'; if(jQuery('#ai-zoom-div-' + obj.id).length!==0){ var zoom=window['zoom_' + obj.id]; jQuery('#ai-zoom-div-' + obj.id).css('height', newheight * zoom); } if(aiEnableCookie&&aiExtraSpace===0){ aiWriteCookie(newheight); } var hash=aiGetIframeHash(obj.contentWindow.location.href); if(hash!==-1){ var iframeId='#'+ obj.id; try { var hashposition=jQuery(iframeId).contents().find('#'+ hash); if(hashposition.length!==0){ var hashpositionTop=hashposition.offset().top; oldScrollposition=Math.round(jQuery(iframeId).offset().top + hashpositionTop); }} catch(e){ }} setTimeout(function(){ jQuery("html,body").scrollTop(oldScrollposition); }, 50); if(resizeWidth==='true'){ var newWidth=aiGetIframeWidth(obj); obj.width=newWidth; obj.style.width=newWidth + 'px'; } var fCallback=window['resizeCallback' + obj.id]; fCallback(); if(window.frameElement!=null){ parent.jQuery('iframe').trigger('onload'); }}else{ setTimeout(function(){ aiResizeIframe(obj, resizeWidth); },100); }} catch(e){ if(console&&console.log){ console.log('Advanced iframe configuration error: You have enabled the resize of the iframe for pages on the same domain. But you use an iframe page on a different domain. You need to use the external workaround like described in the settings. Also check the next log. There the browser message for this error is displayed.'); console.log(e); }} } function aiGetIframeHash(url){ var hash=url.split('#')[1]; return (hash) ? hash:'-1'; } function aiGetIframeHeight(obj){ var bodyHeight=Math.max(obj.contentWindow.document.body.scrollHeight, obj.contentWindow.document.body.offsetHeight, obj.contentWindow.document.documentElement.scrollHeight, obj.contentWindow.document.documentElement.offsetHeight); var newheight=bodyHeight + aiExtraSpace; return newheight; } function aiGetIframeWidth(obj){ var oldWidth=obj.width; obj.width=1; obj.style.width='1px'; var bodyWidth=Math.max(obj.contentWindow.document.body.scrollWidth, obj.contentWindow.document.body.offsetWidth, obj.contentWindow.document.documentElement.scrollWidth, obj.contentWindow.document.documentElement.offsetWidth); if(bodyWidth!==1){ obj.width=bodyWidth; obj.style.width=bodyWidth + 'px'; }else{ obj.width=oldWidth; obj.style.width=oldWidth + 'px'; } return bodyWidth; } function aiGetParentIframeWidth(obj){ if(obj!=null&&jQuery('#' + obj.id).length!==0){ return jQuery('#' + obj.id).width(); }else{ return -1; }} function aiResizeIframeHeightById(id, nHeight){ try { var fCallback=window['resizeCallback' + id]; fCallback(); var height=parseInt(nHeight,10) + aiExtraSpace; var iframe=document.getElementById(id); var oldScrollposition=jQuery(document).scrollTop(); iframe.height=height; iframe.style.height=height + 'px'; jQuery("html,body").scrollTop(oldScrollposition); if(aiEnableCookie&&aiExtraSpace===0){ aiWriteCookie(height); } var parentResizeCall=window['aiExecuteWorkaround_' + id]; if(parentResizeCall!=null){ parentResizeCall(); }} catch(e){ if(console&&console.log){ console.log('Advanced iframe configuration error: The id of the parent and the external workaround are different! Check your settings.'); console.log(e); }} } function aiScrollToTop(id, position){ if(aiOnloadEventsCounter > 0){ var posTop=0; if(position==='iframe'){ posTop=jQuery('#' + id).offset().top; } setTimeout(function(){ window.scrollTo(0, posTop); }, 100); } setTimeout(function(){ aiOnloadEventsCounter++; }, 1000); } function aiWriteCookie(height){ var cookieName='ai-last-height'; if(aiId!==''){ cookieName=cookieName + '-' + aiId ; } var cookieStr=cookieName + '=' + height; document.cookie=cookieStr; } function aiUseCookie(){ var cookieName='ai-last-height'; if(aiId!==''){ cookieName=cookieName + '-' + aiId ; } var allcookies=document.cookie; var cookiearray=allcookies.split(';'); for (var i=0; i < cookiearray.length; i++){ var name=cookiearray[i].split('=')[0]; var value=cookiearray[i].split('=')[1]; if(name===cookieName&&value!==null&&aiIsNumeric(value)){ var iframe=document.getElementById(aiId); iframe.height=parseInt(value,10); iframe.style.height=value + 'px'; }} } function aiIsNumeric(input){ return !isNaN(input); } function aiDisableHeight(){ jQuery('#additional_height').attr('readonly','readonly'); jQuery('#additional_height').val('0'); } function aiEnableHeight(){ jQuery('#additional_height').removeAttr('readonly'); } function aiShowElementOnly(iframeId, showElement){ try { var iframe=jQuery(iframeId).contents().find('body'); var selectedBox=iframe.find(showElement).clone(true,true); iframe.find('*').not(jQuery('script')).remove(); iframe.prepend(selectedBox); } catch(e){ if(console&&console.log){ console.log('Advanced iframe configuration error: You have enabled to show only one element of the iframe for pages on the same domain. But you use an iframe page on a different domain. You need to use the pro version of the external workaround like described in the settings. Also check the next log. There the browser message for this error is displayed.'); console.log(e); }} } function aiCheckIfValidTarget(evt, elements){ var targ; if(!evt){ evt=window.event; } if(evt.target){ targ=evt.target; }else if(evt.srcElement){ targ=evt.srcElement; } if(targ.nodeType===3){ targ=targ.parentNode; } var parts=elements.split(','); for (var i=0; i< parts.length; ++i){ var selectorArray=parts[i].split(':'); if(selectorArray[0].toLowerCase()===targ.nodeName.toLowerCase()){ if(selectorArray.length > 1){ if(targ.id.toLowerCase().indexOf(selectorArray[1].toLowerCase())!==-1){ return true; }}else{ return true; }} } return false; } function aiOpenSelectorWindow (url){ var localWidth=jQuery('#width').val(); var localHeight=jQuery('#ai-height-0').val(); if(localWidth.indexOf('%') >=0||Number(localWidth) < 900){ localWidth=900; } localWidth=Number(localWidth) + 40; if(localWidth > (screen.width)){ localWidth=screen.width; } if(localHeight.indexOf('%') >=0){ localHeight=screen.height; }else{ localHeight=Number(localHeight) + 480; } if(localHeight > (screen.height-50)){ localHeight=screen.height-50; } var options='width='+localWidth+',height='+localHeight+',left=0,top=0,resizable=1,scrollbars=1'; var popup_window=window.open(url, '', options); popup_window.focus(); } function aiDisableAiResizeOptions(value){ jQuery('#onload_resize_delay').prop('readonly',value); jQuery('input[id=store_height_in_cookie1]:radio, input[id=store_height_in_cookie2]:radio').attr('disabled',value); jQuery('#additional_height').prop('readonly', value); jQuery('input[id=onload_resize_width1]:radio, input[id=onload_resize_width2]:radio').attr('disabled',value); jQuery('#resize_on_click').prop('readonly', value); jQuery('#resize_on_click_elements').prop('readonly', value); jQuery('#resize_on_ajax').prop('readonly', value); jQuery('input[id=resize_on_ajax_jquery1]:radio, input[id=resize_on_ajax_jquery2]:radio').attr('disabled',value); var selector='#onload_resize_delay, #store_height_in_cookie1, #additional_height, #onload_resize_width1, '; selector +='#resize_on_click, #resize_on_click_elements, #resize_on_ajax, #resize_on_ajax_jquery1'; aiDisableTextSection(value, selector); } function aiDisablePartOfIframeOptions(value){ jQuery('#show_part_of_iframe_x').prop('readonly',value); jQuery('#show_part_of_iframe_y').prop('readonly',value); jQuery('#show_part_of_iframe_height').prop('readonly',value); jQuery('#show_part_of_iframe_width').prop('readonly',value); jQuery('input[id=show_part_of_iframe_allow_scrollbar_horizontal1]:radio, input[id=show_part_of_iframe_allow_scrollbar_horizontal2]:radio').attr('disabled',value); jQuery('input[id=show_part_of_iframe_allow_scrollbar_vertical1]:radio, input[id=show_part_of_iframe_allow_scrollbar_vertical2]:radio').attr('disabled',value); jQuery('#show_part_of_iframe_next_viewports').prop('readonly',value); jQuery('input[id=show_part_of_iframe_next_viewports_loop1]:radio, input[id=show_part_of_iframe_next_viewports_loop2]:radio').attr('disabled',value); jQuery('#show_part_of_iframe_new_window').prop('readonly',value); jQuery('#show_part_of_iframe_new_url').prop('readonly',value); jQuery('input[id=show_part_of_iframe_next_viewports_hide1]:radio, input[id=show_part_of_iframe_next_viewports_hide2]:radio').attr('disabled',value); jQuery('#show_part_of_iframe_style').prop('readonly',value); jQuery('input[id=show_part_of_iframe_zoom1]:radio, input[id=show_part_of_iframe_zoom2]:radio, input[id=show_part_of_iframe_zoom3]:radio').attr('disabled',value); jQuery('.media-query-input').prop('readonly',value); var selector='#show_part_of_iframe_x, #show_part_of_iframe_y, #show_part_of_iframe_height, #show_part_of_iframe_width, '; selector +='#show_part_of_iframe_allow_scrollbar_horizontal1, #show_part_of_iframe_next_viewports, #show_part_of_iframe_next_viewports_loop1, '; selector +='#show_part_of_iframe_new_window, #show_part_of_iframe_new_url, #show_part_of_iframe_next_viewports_hide1, #show_part_of_iframe_style, '; selector +='#show_part_of_iframe_zoom1, #show_part_of_iframe_allow_scrollbar_vertical1, #add-media-query-show_part_of_iframe_media_query'; aiDisableTextSection(value, selector); if(value){ jQuery('#add-media-query-show_part_of_iframe_media_query').hide(); jQuery('.ai-delete').hide(); }else{ jQuery('#add-media-query-show_part_of_iframe_media_query').show(); jQuery('.ai-delete').show(); }} function aiDisableLazyLoadOptions(value){ jQuery('#enable_lazy_load_threshold').prop('readonly', value); jQuery('#enable_lazy_load_fadetime').prop('readonly', value); jQuery('input[id=enable_lazy_load_reserve_space1]:radio, input[id=enable_lazy_load_reserve_space2]:radio').attr('disabled',value); jQuery('input[id=enable_lazy_load_manual1]:radio, input[id=enable_lazy_load_manual2]:radio, input[id=enable_lazy_load_manual3]:radio').attr('disabled',value); var selector='#enable_lazy_load_threshold, #enable_lazy_load_fadetime, #enable_lazy_load_reserve_space1, #enable_lazy_load_manual1'; aiDisableTextSection(value, selector); } function aiDisableIframeAsLayerOptions(value){ jQuery('input[id=show_iframe_as_layer_full]:radio').attr('disabled',value); jQuery('#show_iframe_as_layer_header_file').prop('readonly', value); jQuery('#show_iframe_as_layer_header_height').prop('readonly', value); jQuery('input[id=show_iframe_as_layer_header_position1]:radio, input[id=show_iframe_as_layer_header_position2]:radio').attr('disabled',value); jQuery('input[id=show_iframe_as_layer_full1]:radio, input[id=show_iframe_as_layer_full2]:radio, input[id=show_iframe_as_layer_full3]:radio').attr('disabled',value); jQuery('input[id=show_iframe_as_layer_keep_content1]:radio, input[id=show_iframe_as_layer_keep_content2]:radio').attr('disabled',value); var selector='#show_iframe_as_layer_full, #show_iframe_as_layer_header_file, #show_iframe_as_layer_header_height, '; selector +='#show_iframe_as_layer_header_position1, #show_iframe_as_layer_full1, #show_iframe_as_layer_keep_content1'; aiDisableTextSection(value, selector); } function aiDisableTextSection(value, selector){ if(value){ jQuery(selector).closest('tr').addClass('disabled'); }else{ jQuery(selector).closest('tr').removeClass('disabled'); }} var aiInstance; function aiInitAdminConfiguration(isPro, acc_type){ if(jQuery('input[type=radio][name=onload_resize]:checked').val()==='false'){ aiDisableAiResizeOptions(true); } jQuery('input[type=radio][name=onload_resize]').click(function(){ if(jQuery(this).val()==='true'){ jQuery('input:radio[name=enable_external_height_workaround]')[1].checked=true; aiDisableAiResizeOptions(false); }else{ jQuery('#onload_resize_delay').val(''); aiDisableAiResizeOptions(true); }}); jQuery('input[type=radio][name=enable_external_height_workaround]').click(function(){ if(jQuery(this).val()==='true'){ jQuery('input:radio[name=onload_resize]')[1].checked=true; jQuery('#onload_resize_delay').val(''); aiDisableAiResizeOptions(true); }}); if(jQuery('input[type=radio][name=show_part_of_iframe]:checked').val()==='false'){ aiDisablePartOfIframeOptions(true); } jQuery('input[type=radio][name=show_part_of_iframe]').click(function(){ if(jQuery(this).val()==='false'){ aiDisablePartOfIframeOptions(true); }else{ aiDisablePartOfIframeOptions(false); }}); if(jQuery('input[type=radio][name=show_iframe_as_layer]:checked').val()==='false'){ aiDisableIframeAsLayerOptions(true); } jQuery('input[type=radio][name=show_iframe_as_layer]').click(function(){ if(jQuery(this).val()==='false'){ aiDisableIframeAsLayerOptions(true); }else{ aiDisableIframeAsLayerOptions(false); }}); if(jQuery('input[type=radio][name=expert_mode]:checked').val()==='true'){ jQuery('.description').css('display','none'); jQuery('table.form-table th').css('cursor','pointer'); jQuery('table.form-table th').css('padding-top','8px').css('padding-bottom','2px'); jQuery('table.form-table td').css('padding-top','5px').css('padding-bottom','5px'); jQuery('table.form-table th').click(function(){ jQuery('.description').css('display','none'); jQuery('.description', jQuery(this).parent()).css('display','block'); }); } jQuery('input[type=radio][name=expert_mode]').click(function(){ if(jQuery(this).val()==='false'){ jQuery('.description').css('display','block'); jQuery('table.form-table th').css('cursor','auto'); jQuery('table.form-table th').off('click'); jQuery('table.form-table th').css('padding-top','20px').css('padding-bottom','20px'); jQuery('table.form-table td').css('padding-top','15px').css('padding-bottom','15px'); }else{ jQuery('.description').css('display','none'); jQuery('table.form-table th').css('cursor','pointer'); jQuery('table.form-table th').css('padding-top','8px').css('padding-bottom','2px'); jQuery('table.form-table td').css('padding-top','5px').css('padding-bottom','5px'); jQuery('table.form-table th').click(function(){ jQuery('.description').css('display','none'); jQuery('.description', jQuery(this).parent()).css('display','block'); }); }}); jQuery('#accordion').find('h1').click(function(){ jQuery(this).next().slideToggle(aiAccTime); }).next().hide(); jQuery('#accordion').find('a').click(function(){ var hash=jQuery(this).prop('hash'); var hash_only='#h1-' + hash.substring(1); jQuery(hash_only).next().show(); location.hash=hash_only; }); if(jQuery('input[type=radio][name=enable_lazy_load_manual]:checked').val()==='false'){ jQuery('#enable_lazy_load_manual_element').prop('readonly',true); } jQuery('input[type=radio][name=enable_lazy_load_manual]').click(function(){ if(jQuery(this).val()==='false'||jQuery(this).val()==='auto'){ jQuery('#enable_lazy_load_manual_element').prop('readonly',true); }else{ jQuery('#enable_lazy_load_manual_element').prop('readonly',false); }}); if(jQuery('input[type=radio][name=enable_lazy_load]:checked').val()==='false'){ aiDisableLazyLoadOptions(true); jQuery('#enable_lazy_load_manual_element').prop('readonly',true); } jQuery('input[type=radio][name=enable_lazy_load]').click(function(){ if(jQuery(this).val()==='false'){ aiDisableLazyLoadOptions(true); jQuery('#enable_lazy_load_manual_element').prop('readonly',true); }else{ aiDisableLazyLoadOptions(false); if(jQuery('input[type=radio][name=enable_lazy_load_manual]:checked').val()==='false' || jQuery('input[type=radio][name=enable_lazy_load_manual]:checked').val()==='auto'){ jQuery('#enable_lazy_load_manual_element').prop('readonly',true); }else{ jQuery('#enable_lazy_load_manual_element').prop('readonly', false); }} }); jQuery('.confirmation').on('click', function (){ return confirm('Are you sure? Selecting OK will set all settings to the default.'); }); jQuery('a.post').click(function(e){ e.stopPropagation(); e.preventDefault(); var href=this.href; var parts=href.split('?'); var url=parts[0]; var params=parts[1].split('&'); var pp, inputs=''; url +='?' + params[0]; for(var i=1, n=params.length; i < n; i++){ pp=params[i].split('='); inputs +=''; } jQuery('body').append('
'); jQuery('#poster').submit(); }); jQuery('.ai-input-search').keyup(function(e){ var searchTerm=jQuery('input.ai-input-search').val().toLowerCase(); aiSettingsSearch(searchTerm, acc_type); }); jQuery('.ai-input-search').on('click', function(e){ setTimeout(function(){ var searchTerm=jQuery('input.ai-input-search').val().toLowerCase(); aiSettingsSearch(searchTerm, acc_type); }, 100); }); jQuery(document).on('click', '.nav-tab-wrapper a', function(){ var current_tab=jQuery(this).attr('id'); jQuery('section').hide(); jQuery('section.' + current_tab).show(); jQuery('#current_tab').val(current_tab.substr(4,1)); jQuery('.nav-tab').removeClass('nav-tab-active'); jQuery(this).addClass('nav-tab-active'); jQuery(this).blur(); return false; }); jQuery(document).on('click', 'a#external-workaround-link', function(){ jQuery('.external-workaround').click(); location.hash='tab_3'; aiShowHeader('tab_3'); return false; }); jQuery(document).on('click', 'a#resize-same-link', function(){ jQuery('.advanced-settings-tab').click(); jQuery('#id-advanced-resize').removeClass('closed'); location.hash='id-advanced-resize'; aiShowHeader('id-advanced-resize'); return false; }); jQuery(document).on('click', 'a.jquery-help-link', function(){ jQuery('.help-tab').click(); jQuery('#id-help-jquery').removeClass('closed'); jQuery('#jquery-help').show(); location.hash='id-help-jquery'; aiShowHeader('id-help-jquery'); return false; }); jQuery(document).on('click', 'a#browser-detection-link', function(){ jQuery('.help-tab').click(); jQuery('#id-help-browser').removeClass('closed'); jQuery('#browser-help').show(); location.hash='id-help-browser'; aiShowHeader('id-help-browser'); return false; }); jQuery(document).on('click', 'a.howto-id-link', function(){ jQuery('.help-tab').click(); jQuery('#id-help-id').removeClass('closed'); location.hash='id-help-id'; aiShowHeader('id-help-id'); return false; }); jQuery(document).on('click', '.modifycontent-link', function(){ jQuery('.advanced-settings-tab').click(); jQuery('#id-advanced-modify-iframe').removeClass('closed'); location.hash='id-advanced-modify-iframe'; aiShowHeader('id-advanced-modify-iframe', 'tr-' + jQuery(this).data('detail')); return false; }); jQuery(document).on('click', '.id-modify-css-iframe-link', function(){ jQuery('.advanced-settings-tab').click(); jQuery('#id-advanced-modify-iframe').removeClass('closed'); location.hash='id-modify-css-iframe'; aiShowHeader('id-advanced-modify-iframe', 'tr-' + jQuery(this).data('detail')); return false; }); jQuery(document).on('click', '.modify-target', function(){ jQuery('.advanced-settings-tab').click(); jQuery('#id-advanced-modify-iframe').removeClass('closed'); location.hash='id-modify-target'; aiShowHeader('id-advanced-modify-iframe', 'tr-' + jQuery(this).data('detail')); return false; }); jQuery(document).on('click', 'a.link-external-domain', function(){ jQuery('#id-external-different').removeClass('closed'); location.hash='#id-external-different'; aiShowHeader('id-external-different'); return false; }); jQuery(document).on('click', 'a.link-id-external-ai-config-post', function(){ jQuery('#id-external-ai-config-post').removeClass('closed'); location.hash='#id-external-ai-config-post'; aiShowHeader('id-external-ai-config-post', 'tr-use_post_message'); return false; }); jQuery(document).on('click', 'a.link-id-external-ai-overview', function(){ jQuery('#id-external-ai-overview').removeClass('closed'); location.hash='#id-external-ai-overview'; aiShowHeader('id-external-ai-overview', 'id-external-ai-overview'); return false; }); jQuery(document).on('click', 'a.post-message-help-link', function(){ jQuery('.help-tab').click(); jQuery('#id-help-communication').removeClass('closed'); location.hash='#id-help-communication'; aiShowHeader('id-help-communication','id-help-communication'); return false; }); jQuery(document).on('click', 'a.enable-admin', function(){ jQuery('.options-tab').click(); jQuery('#id-options-display').removeClass('closed'); location.hash='#id-options-display'; aiShowHeader('id-options-display', 'tr-demo'); return false; }); jQuery(document).on('click', 'a#user-help-link', function(){ jQuery('#user-help').css('display', 'block'); return false; }); jQuery(document).on('click', 'a#user-meta-link', function(){ jQuery('#meta-help').css('display', 'block'); return false; }); jQuery(document).on('click', '#ai-selector-help-link', function(){ jQuery('#ai-selector-help').slideDown(1000); return false; }); jQuery(document).on('click', '.ai-selector-help-link-move', function(){ jQuery('#ai-selector-help').show('slow'); location.hash='#ai-selector-help-link'; aiShowHeader('ai-selector-help-link'); return false; }); jQuery('#ai_form').submit(function(){ aiSetScrollposition(); }); jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed'); if(typeof postboxes!=='undefined'){ postboxes.add_postbox_toggles('toplevel_page_advanced-iframe'); } jQuery('.ai-spinner').css('display','none'); jQuery("#" + acc_type).next().show(); jQuery(document).on('click', '#test-pro-admin.is-permanent-closable button', function(){ closeInfoPermanent('test-pro-admin'); }); jQuery(document).on('click', '.mq-breakpoint-height a', function(evt){ jQuery(this).parent().remove(); aiUpdateHeightHiddenField('height'); evt.preventDefault(); return false; }); jQuery(document).on('click', 'a#add-media-query-height', function(evt){ var nextNr=jQuery(".mq-breakpoint-height").length + 1; jQuery(this).parent().append('r: ' + debugData + '
'); }} function aiProcessScrollToTop(jsObject){ var id=jsObject.id; aiScrollToTop(id, aiOnloadScrollTop); } function aiProcessHeight(jsObject){ var nHeight=jsObject.height; var nWidth=jsObject.width; var iAnchor=parseInt(jsObject.anchor,10); var id=jsObject.id; if(nHeight!=null){ try { var loc=jsObject.loc; if(loc!=null){ aiChangeUrl(loc); } if(id!=null){ var iHeight=parseInt(nHeight,10); var iWidth=parseInt(nWidth,10); aiResizeIframeHeightId(iHeight,iWidth, id); if(!isNaN(iAnchor)&&iAnchor > -1){ var iframeTop=jQuery("#" + id).offset().top; setTimeout(function(){ jQuery("html,body").scrollTop(Math.round(iframeTop + iAnchor)); aiShowIframeId(id); }, 100); }else{ aiShowIframeId(id); }}else{ alert('Please update the ai_external.js to the current version.'); }} catch(e){ if(console&&console.log){ console.log(e); }} }} function aiProcessShow(jsObject){ var id=jsObject.id; try { aiShowIframeId(id); } catch(e){ if(console&&console.log){ console.log(e); }} } function aiRemoveElementsFromHeight(id,height,removeElements){ var iframe=jQuery('#' + id); var elementArray=removeElements.split(','); var totalHeight=0; for (var i=0; i < elementArray.length; i++){ try { var el=elementArray[i]; if(el.includes("|")){ var rangeArray=el.split('|'); var bottomElement=jQuery(rangeArray[0]); var beforeBottom=Math.round(bottomElement.offset().top + bottomElement.outerHeight(true)); var nextTop=Math.round(jQuery(rangeArray[1]).offset().top); totalHeight +=nextTop - beforeBottom; }else if(el==='top'){ totalHeight +=Math.round(jQuery('#' + id).offset().top); }else if(isNaN(el)){ totalHeight +=jQuery(el).outerHeight(true); }else{ totalHeight +=parseInt(el); }} catch(e){ if(console&&console.log){ console.log('Advanced iframe configuration error: The configuration of remove_elements_from_height "'+removeElements+'" is invalid. Please check if the elements you defined do exist and ids/classes are defined properly.'); console.log(e); }} } var calc='calc(' + height + ' - ' + totalHeight + 'px)'; iframe.css('height', calc); } if(!String.prototype.includes){ String.prototype.includes=function(search, start){ if(typeof start!=='number'){ start=0; } if(start + search.length > this.length){ return false; }else{ return this.indexOf(search, start)!==-1; }};};